﻿#region License | GNU GPL v3

//Up2Date Framework - Update framework for application developers
//Copyright (C) 2012  Aldo Giese IT-Services

//This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License 
//as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
//This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
//of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

//You should have received a copy of the GNU General Public License along with this program;
//if not, see <http://www.gnu.org/licenses/>.

#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Up2DateFramework;

namespace ConsoleSample
{
    class Program
    {
        static void Main(string[] args)
        {
            //Setup des Frameworks
            HashSet<string> listRemote;     // Liste für die Remote Daten (lokal simuliert)
            HashSet<string> listLocal;      // Liste für Lokale Daten

            string currentDir = Path.Combine(Environment.CurrentDirectory, "content");      // Pfad zum Testordner

            //U2D.StandardSeparator = ":";                                                    //<-- wenn nicht gesetzt dann standard (":")
            //U2D.RemoteUpdatePath = "http://u2d.aldo-giese.de/update";
            //U2D.UpdateFileName = "http://u2d.aldo-giese.de/versions.txt";
            U2D.LocalUpdatePath = Path.Combine(Environment.CurrentDirectory, "content");    // Lokaler Update Path
            U2D.ActivateLogOutput = true;                                                   // Log Messages
            U2D.UpdateLogName = "u2dlog.txt";                                               // Log File Name
            U2D.UpdateFileName = "versions.txt";                                            // U2D Update File Name
            U2D.RemoveSplitChar = true;
            
            Console.WriteLine("====== Up2Date Framework Demo Application ====== by Aldo Giese IT-Services\n");

            // Für Zeitmessung
            Stopwatch watch = new Stopwatch();
            watch.Start();

            // Dieses Snippet zeigt den einfachen Einsatz des errechnens einer Checksumme einer einzelnen Datei
            FileInfo fi = new FileInfo(currentDir+"\\s1\\b.txt");

            foreach (var item in listLocal = U2D.GenerateLocalList(currentDir+"\\s1",U2D.ChecksumsHashes.SuperFast))
            {
                Console.WriteLine(item);
            }


            foreach (string s in listLocal)
                Console.WriteLine("Compress:{0}", Compressor.GenerateOneZipArchiveEachFile(currentDir, s));

            Compressor.ListAllEntries(currentDir + "\\b.zip");

            Console.WriteLine("\n");
            //foreach (var item in U2D.GenerateLocalList(currentDir + "\\s2", U2D.ChecksumsHashes.FNV1a))
            //{
            //    Console.WriteLine(item);
            //}

            watch.Stop();

            // Stoppuhr restarten, vorher aktuelle Zeit ausgeben
            Console.WriteLine("\n\nDauer des Ladens der beiden Listen: {0}\n", watch.Elapsed);
          

            Console.ReadLine();
        }
       
    }
}
